<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Document</title>
</head>

<body>
  <script>
    let arr = [1, 2, [3, 4, 5, [6, 7]], [8, [9, [10, [11]]]]];
    function getDepth(arr) {
      if (!Array.isArray(arr)) {
        // 判断是否为数组
        return 0;
      }
      let depth = 1; // 初始化深度为 1
      for (let i = 0; i < arr.length; i++) {
        const cur = arr[i];
        if (Array.isArray(cur)) {
          // 如果当前元素仍为数组，递归遍历
          const curDepth = getDepth(cur) + 1;
          depth = Math.max(depth, curDepth);
        }
      }
      return depth;
    }
    console.log([123] == [123]);
    console.log(getDepth(arr));
  </script>
</body>

</html>